package com.game.logic.core.comment;

import com.xs.tool.formula.DrawCardsFormula;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 礼包池
 * @param BonusPoll 礼包池
 * @param num 共掉落数量
 * @param <T> 掉落的礼品对象
 */
@Slf4j
public record BonusPoll<T>(
        DrawCardsFormula<Bonus<T>> BonusPoll, int num
) {
    public List<T> obtainDrop() {
        long start = System.currentTimeMillis();
        List<Bonus<T>> draw = BonusPoll.draw(num);
        List<T> list = draw.stream().map(Bonus::getBonusValue).flatMap(List::stream).toList();
        log.info("消耗时间:{}ms", System.currentTimeMillis() - start);
        return list;
    }

    public List<Bonus<T>> obtainDropBonus() {
        return BonusPoll.draw(num);
    }
}
